import 'dart:convert';

/// avatar : "/avatar.img"
/// content : "我是谢瑶！"
/// roomId : "0a361a3472d040f28f1150b57a903e44"
/// senderId : "dc8de867d25d470489db4504809e52c4"
/// sentAt : "2023-05-11 22:39:03"
/// sentType : "1"
/// nickName : ""

MessageBean messageBeanFromJson(String str) =>
    MessageBean.fromJson(json.decode(str));

String messageBeanToJson(MessageBean data) => json.encode(data.toJson());

class MessageBean {
  MessageBean({
    String? avatar,
    String? content,
    String? roomId,
    String? senderId,
    String? sentAt,
    String? sentType,
    String? nickName,
  }) {
    _avatar = avatar;
    _content = content;
    _roomId = roomId;
    _senderId = senderId;
    _sentAt = sentAt;
    _sentType = sentType;
    _nickName = nickName;
  }

  MessageBean.fromJson(dynamic json) {
    _avatar = json['avatar'];
    _content = json['content'];
    _roomId = json['roomId'];
    _senderId = json['senderId'];
    _sentAt = json['sentAt'];
    _sentType = json['sentType'];
    _nickName = json['nickName'];
  }

  String? _avatar;
  String? _content;
  String? _roomId;
  String? _senderId;
  String? _sentAt;
  String? _sentType;
  String? _nickName;

  MessageBean copyWith({
    String? avatar,
    String? content,
    String? roomId,
    String? senderId,
    String? sentAt,
    String? sentType,
    String? nickName,
  }) =>
      MessageBean(
        avatar: avatar ?? _avatar,
        content: content ?? _content,
        roomId: roomId ?? _roomId,
        senderId: senderId ?? _senderId,
        sentAt: sentAt ?? _sentAt,
        sentType: sentType ?? _sentType,
        nickName: nickName ?? _nickName,
      );

  String? get avatar => _avatar;

  String? get content => _content;

  String? get roomId => _roomId;

  String? get senderId => _senderId;

  String? get sentAt => _sentAt;

  String? get sentType => _sentType;

  String? get nickName => _nickName;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['avatar'] = _avatar;
    map['content'] = _content;
    map['roomId'] = _roomId;
    map['senderId'] = _senderId;
    map['sentAt'] = _sentAt;
    map['sentType'] = _sentType;
    map['nickName'] = _nickName;
    return map;
  }
}
